///////////* SOM Manager by Zyphir */////////////

function som_manager(som_manager_script_nb, som_manager_version){
  var som_scripts_list = [[20110626],
  ['TW Pro+','92414','Zyphir','public'],['TW Pro+','93313','Zyphir','beta'],
  ['Buffalo Bill','104485','Dun','public'],
//  ['Shortcuts','92957','Gzahab','public'],
  ['Forts Manager','86724','Zyphir','public'],['Forts Manager','94510','Zyphir','beta'],
  ['Notepad','105517','Dun','public'],
//  ['ChatRoom','95'+'135','Y.','public'],
  ['Duel Page','105518','Dun','public'],
  ['Wardrobe','105509','Dun','public'],
  ['Vote on JA (fr)','98477','Zyphir','public']];

  function create_som_div(){
	  var beta = false;
	  var som_scripts_div = document.createElement('div');
	  som_scripts_div.id = "som_scripts_div";
	  som_scripts_div.style.cssText = "position:absolute;float:left;font-Size:10px;left:-100px;bottom:10px;display:none;z-index:9999";
    var som_scripts_div_table = '<table id="show_hide"><tr><td><table id="som_scripts_table" style="border: solid 1px #666666;background: url(../images/profile/settings_profile_input_bg.png);font-size:12px;vertical-align:top;">';
	  var som_scripts_div_table_beta = '';

	  for(var i=1;i<som_scripts_list.length;i++){
		if(som_scripts_list[i][1]==som_manager_script_nb){
			som_scripts_list[i].push(1, som_manager_version);
		}
		if(som_scripts_list[i][3]!='beta'){
			som_scripts_div_table += '<tr><td><img id="active_som_script_'+som_scripts_list[i][1]+'" src="/images/confirm_buttons/'+(som_scripts_list[i][4]==1?'yes':'no')+'.png" width="16" height="16" title="'+(som_scripts_list[i][5]?'<b>'+som_scripts_list[i][5]+'</b>':'')+'"></td><td><a href="http://userscripts.org/scripts/show/'+som_scripts_list[i][1]+'" target="_blank" onclick="show_som_scripts();som_scripts_div.onmouseout=function(){void(0);}">'+som_scripts_list[i][0]+'</a></td><td>'+som_scripts_list[i][2]+'</td></tr>';
		}
		else{
			som_scripts_div_table_beta += '<tr><td><img id="active_som_script_'+som_scripts_list[i][1]+'" src="/images/confirm_buttons/'+(som_scripts_list[i][4]==1?'yes':'no')+'.png" width="16" height="16" title="'+(som_scripts_list[i][5]?'<b>'+som_scripts_list[i][5]+'</b>':'')+'"></td><td><a href="http://userscripts.org/scripts/show/'+som_scripts_list[i][1]+'" target="_blank"onclick="show_som_scripts();som_scripts_div.onmouseout=function(){void(0);}">'+som_scripts_list[i][0]+'</a></td><td>'+som_scripts_list[i][2]+'</td></tr>';
			beta = true;
		}
	  }
	  
	  if(beta==true) som_scripts_div_table += "<tr><td colspan='3' style='text-align:center;'><b>Beta versions</b> <span style='cursor:help;color:darkred;font-weight:bold;' title=\"<span style=\'color:darkred;font-weight:bold;\'>/!\\ These are BETA-DEV versions /!\\</span><br>Please do not share these scripts on public forums as they are not always up-to-date,<br>they can have very annoying bugs and we can not guarantee the follow-up.<br><b>We always recommend to use the final releases available above.</b>\"> <small>Readme </small>/!\\</span></td></tr>"+som_scripts_div_table_beta;
	  som_scripts_div_table += '</table></td></tr></table>';
	  som_scripts_div.innerHTML = som_scripts_div_table;
	  document.getElementById('main_footnotes').appendChild(som_scripts_div);
    }

 if(document.getElementById('som_scripts_manager')){
	/*if(som_scripts_list[0] > document.getElementById('som_button').name){ // liste plus récente trouvée
		for(var i=1;i<som_scripts_list.length;i++){
			if(document.getElementById('active_som_script_'+som_scripts_list[i][1])){
				if(document.getElementById('active_som_script_'+som_scripts_list[i][1]).src.indexOf('yes.png')!=-1){
					som_scripts_list[i].push(1, document.getElementById('active_som_script_'+som_scripts_list[i][1]).title);
				}
			}			
		}
		document.getElementById('som_scripts_div').parentNode.removeChild(document.getElementById('som_scripts_div'));
		create_som_div();
	}
	else if(document.getElementById('active_som_script_'+som_manager_script_nb)){ // on met à jour
	 */document.getElementById('active_som_script_'+som_manager_script_nb).src="/images/confirm_buttons/yes.png";
		document.getElementById('active_som_script_'+som_manager_script_nb).title='<b>'+som_manager_version+'</b>';
	//}
 }
 else{
	function show_som_scripts(){
		if(document.getElementById('workbar_left')){
			if(document.getElementById('som_scripts_div').style.display == "none"){
			  document.getElementById('workbar_left').style.zIndex="1";
			  document.getElementById('som_scripts_div').style.display = "block";
        document.getElementById('som_scripts_div').onmouseover=function(event){if (event.target.id == 'som_scripts_table')document.getElementById('som_scripts_div').onmouseout=function(event){if (event.target.id == 'show_hide'){show_som_scripts();document.getElementById('som_scripts_div').onmouseout=function(){void(0);};}};};  
      }
			else{
  			document.getElementById('workbar_left').style.zIndex="5";
			  document.getElementById('som_scripts_div').style.display = "none";
        document.getElementById('som_scripts_div').onmouseover=function(){void(0);};
        document.getElementById('som_scripts_div').onmouseout=function(){void(0);};
			}
		}
	}
	window.show_som_scripts = show_som_scripts;
	var som_button = document.createElement('div');
	som_button.style.cssText = "position:absolute;float:left;font-Size:10px;left:-100px;top:12px";
	som_button.id = "som_button";
	som_button.name = som_scripts_list[0];
	som_button.innerHTML = '<div id="som_scripts_manager"><a href="javascript:window.show_som_scripts();"><img title="<b>SOM Manager</b>" src=""></a></div>';
	document.getElementById('main_footnotes').appendChild(som_button);
	create_som_div();
 }
}
//window.som_manager = som_manager;

///////////* end SOM Manager */////////////